home *** CD-ROM | disk | FTP | other *** search
- /*
- * name: merge
- *
- * description: merge sourceword with destinationword using the
- * boolean operation specified by the function code f.
- *
- * synopsis: unsigned short merge (sourceword, destinationword, f)
- * unsigned short sourceword;
- * unsigned short destinationword;
- * int f;
- *
- * globals: allones (r)
- *
- * calls: nothing.
- *
- * called by: bitblt (bitblt.c)
- */
- #include "layers.h"
-
- extern unsigned short allones;
-
- unsigned short merge (sourceword, destinationword, f)
- unsigned short sourceword;
- unsigned short destinationword;
- int f;
- {
- /*
- * these are the 16 combination rules
- */
- switch (f) {
- case all_zeros:
- return (0);
- case s_and_d:
- return (sourceword & destinationword);
- case s_and_nd:
- return (sourceword & ~destinationword);
- case s:
- return (sourceword);
- case ns_and_d:
- return (~sourceword & destinationword);
- case d:
- return (destinationword);
- case s_xor_d:
- return (sourceword ^ destinationword);
- case s_or_d:
- return (sourceword | destinationword);
- case ns_and_nd:
- return (~sourceword & ~destinationword);
- case ns_xor_d:
- return (~sourceword ^ destinationword);
- case nd:
- return (~destinationword);
- case s_or_nd:
- return (sourceword | ~destinationword);
- case ns:
- return (~sourceword);
- case ns_or_d:
- return (~sourceword | destinationword);
- case ns_or_nd:
- return (~sourceword | ~destinationword);
- case all_ones:
- return (allones);
- }
- }